//---------------------------------------------------------------------------

#include "LangUtil.h"

//---------------------------------------------------------------------------

WORD getKeyboardLanguage(DWORD t)
{
  return LOWORD(GetKeyboardLayout(t)); // LCID
}

const char *getKeyboardLanguageName(void)
{
  static char szKLStorage[KL_NAMELENGTH] = "";
  GetKeyboardLayoutName(szKLStorage);
  return &szKLStorage[0];
}

void switchKeyboardLanguage(WORD lcid, DWORD t)
{
  DWORD current = GetCurrentThreadId();
  if(current != t)
  {
    AttachThreadInput(current, t, true);
  }

  PostMessage(GetFocus(), WM_INPUTLANGCHANGEREQUEST, 0, LPARAM(lcid));

  if(current != t)
  {
    AttachThreadInput(current, t, false);
  }
}

